home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / dev / misc / libx11.lha / libX11 / xtoolkit2.c < prev   
Encoding:
C/C++ Source or Header  |  1996-09-22  |  4.6 KB  |  194 lines

  1. /* Copyright (c) 1996 by Terje Pedersen.  All Rights Reserved   */
  2. /*                                                              */
  3. /* By using this code you will agree to these terms:            */
  4. /*                                                              */
  5. /* 1. You may not use this code for profit in any way or form   */
  6. /*    unless an agreement with the author has been reached.     */
  7. /*                                                              */
  8. /* 2. The author is not responsible for any damages caused by   */
  9. /*    the use of this code.                                     */
  10. /*                                                              */
  11. /* 3. All modifications are to be released to the public.       */
  12. /*                                                              */
  13. /* Thats it! Have fun!                                          */
  14. /* TP                                                           */
  15. /*                                                              */
  16.  
  17. /***
  18.    NAME
  19.      xtoolkit2
  20.    PURPOSE
  21.      attempt to use MUI as a base for X11 applications!
  22.    NOTES
  23.      
  24.    HISTORY
  25.      Terje Pedersen - Dec 14, 1994: Created.
  26. ***/
  27.  
  28. #include "libX11.h"
  29.  
  30. #include <intuition/intuition.h>
  31. #include <intuition/intuitionbase.h>
  32.  
  33. #include <graphics/gfx.h>
  34. #include <graphics/gfxbase.h>
  35. #include <graphics/gfxmacros.h>
  36. #include <graphics/displayinfo.h>
  37. #include <devices/timer.h>
  38.  
  39. #include <proto/intuition.h>
  40. #include <proto/graphics.h>
  41. #include <proto/gadtools.h>
  42. #include <proto/layers.h>
  43.  
  44. #include <dos.h>
  45. #include <signal.h>
  46. #include <stdlib.h>
  47. #include <time.h>
  48. #include <stdio.h>
  49.  
  50. #define XLIB_ILLEGAL_ACCESS 1
  51.  
  52. #include <X11/X.h>
  53. #include <X11/Xlib.h>
  54. #include <X11/Xutil.h>
  55. #include <X11/Intrinsic.h>
  56. #include <X11/Stringdefs.h>
  57.  
  58. /*
  59. #include <X11/IntrinsicP.h>
  60. #include <X11/Core.h>
  61. #include <X11/CoreP.h>
  62. */
  63.  
  64. #include <libraries/mui.h>
  65. #include <proto/muimaster.h>
  66.  
  67. struct ObjApp{
  68.   APTR App;
  69.   APTR Root;
  70.   APTR Canvas;
  71. } *X11App = NULL;
  72.  
  73. struct ObjApp *createMUI_app(char *title){
  74.   struct ObjApp * Object;
  75.  
  76.   if (!(Object = AllocVec( sizeof( struct ObjApp ), MEMF_PUBLIC|MEMF_CLEAR ))) return( NULL );
  77.   Object->App = ApplicationObject,
  78.         MUIA_Application_Author, "TP",
  79.         MUIA_Application_Base, "NONE",
  80.         MUIA_Application_Title, title,
  81.         MUIA_Application_Version, "$VER: NONE XX.XX (XX.XX.XX)",
  82.         MUIA_Application_Copyright, "NOBODY",
  83.         MUIA_Application_Description, "NONE",
  84.         SubWindow, Object->Root = WindowObject,
  85.           WindowContents, Object->Canvas=GroupObject, End,
  86.         End,  
  87.   End;
  88.  
  89.   if (!(Object->App)){
  90.     FreeVec(Object);
  91.     Object = NULL;
  92.   }
  93.   return(Object);
  94. }
  95.  
  96.  
  97. Widget XtInitialize(shell_name, application_class, options,
  98.             num_options, argc, argv)
  99.      String shell_name;    /* unused */
  100.      String application_class;
  101.      XrmOptionDescRec options[];
  102.      Cardinal num_options;
  103.      Cardinal *argc;
  104.      char *argv[];
  105.  
  106. {/*            File 'xlogo.o'*/
  107. #ifdef DEBUGXEMUL
  108.   printf("XtInitialize\n");
  109. #endif
  110.   X11App=createMUI_app(shell_name);
  111.  
  112.   return(X11App->App);
  113. }
  114.  
  115. void XtMainLoop(){/*              File 'xlogo.o'*/
  116.   int running=TRUE;
  117.   ULONG sigs;
  118. #ifdef DEBUGXEMUL
  119.   printf("XtMainLoop\n");
  120. #endif
  121. /*  XtAppMainLoop(amiga_Context);*/
  122.   while (running){
  123.     switch (DoMethod(X11App->App,MUIM_Application_Input,&sigs)){
  124.     case MUIV_Application_ReturnID_Quit: running=FALSE;
  125.       break;
  126.     }
  127.     if (running && sigs) Wait(sigs);
  128.   }
  129.   return(0);
  130. }
  131.  
  132. /*
  133. extern struct IClass *MyClass;
  134. #define MyObject NewObject(MyClass,NULL
  135. */
  136.  
  137. const ULONG sourcecolors[6] ={
  138.   0xb4b4b4b4,0xb4b4b4b4,0xb4b4b4b4,
  139.   0x00000000,0x00000000,0x00000000,
  140. };
  141.  
  142. Widget XtCreateManagedWidget(name, widget_class, parent,
  143.                  args, num_args)
  144.      String name;
  145.      WidgetClass widget_class;
  146.      Widget parent;
  147.      ArgList args;
  148.      Cardinal num_args;
  149. {
  150.   Object *newobj=NULL,*bmobj=NULL;
  151.   if(args[0].name==XtNbitmap){
  152.     struct BitMap *bm=(struct BitMap*)args[0].value;
  153.     bmobj=BitmapObject,
  154.       ButtonFrame,
  155.       MUIA_InputMode, MUIV_InputMode_RelVerify,
  156.       MUIA_Bitmap_Bitmap,bm,
  157.       MUIA_Bitmap_Height,bm->Rows,
  158.       MUIA_Bitmap_Width,bm->BytesPerRow*8,
  159.       MUIA_FixWidth,bm->BytesPerRow*8,
  160.       MUIA_FixHeight,bm->Rows,
  161.       MUIA_Bitmap_Transparent,0,
  162.       MUIA_Bitmap_SourceColors,sourcecolors,
  163.       MUIA_Background,MUII_ButtonBack,
  164.     End;
  165.   }
  166.  
  167.   switch((int)widget_class){
  168. /*
  169.   case xmDrawingAreaWidgetClass:
  170.     newobj=MyObject,
  171.         MUIA_FixWidth,100,
  172.     MUIA_FixHeight,100,
  173.       End;
  174.     break;*/
  175.   case commandWidgetClass:
  176.     if(bmobj) newobj=bmobj;
  177.     break;
  178.   }
  179.   if(newobj)
  180.     DoMethod(parent,OM_ADDMEMBER,newobj);
  181. }
  182.  
  183. void XtDestroyWidget(w)
  184.      Widget w;
  185. {
  186. }
  187.  
  188.  
  189. void XtRealizeWidget(w)
  190.      Widget w;
  191. {
  192.   set(w,MUIA_Window_Open,TRUE);
  193. }
  194.